'use strict';{let p=a=>a==_ij?"Move":_jf(a),k=a=>a==_Ny?{num:a,devId:_Nh}:_3j(a,!0),q=a=>_ao(a)||"pause",r=function(a){var c=k(a.keyId),d=null==a.action?"":a.action;c=`${q(c.devId)} ${d.in("D","DU")?"down":""}`+` ${d.in("U","DU")?"up":""} ${_Yh(c)&&a.hold?"hold":""}`;d=a.keyId==_ij?`<coors>${a.dX||0}<br>${a.dY||0}</coors>`:"";let f=a.keyId==_Ny?`<slp>${a.hold}</slp>`:"";return _Bj(_lo)`<inp class="${c}" value value=$${a} title="Click for options">${p(a.keyId)} <d d></d><d u></d> ${d} ${f} ${1<a.repeat?
`<r>&times;${a.repeat}</r>`:""}</inp>`},t=function(a){return _Bj`<sep></sep> ${r(a)}`},n=0,l=function(a){let c=r(a.value);a.popupElem&&(a.popupElem.popupTriggerElem=$(c).prop("popupElem",a.popupElem).addClass("popup")[0]);$(a).replaceWith(c);n=Date.now()},u=function(a){return!a.hold&&!a.dX&&!a.dY&&!a.wrtObj},m=function(a){$(a).prev("sep.edit")[0]&&$(a).next("sep").addClass("edit");$(a).prev("sep").remove();a.remove()},v=function(a,c){if(!a)return!1;a=a.value;return a.keyId==c&&"DU"==a.action&&u(a)},
w={},z=function(a,c){let d=k(a);if(d.devId.in(_ps,_Lk,_Nh)){if(d.devId==_ps){var f=w[d.num];w[d.num]=d.type==_Ku}a={keyId:d.num,action:a==_ij?void 0:d.type==_Ku?"D":d.type==_Go?"U":void 0,hold:d.devId==_Nh?.5:void 0};let e=c.prevAll("inp");if(e[0]){let b=e[0].value;if(b.keyId==a.keyId&&a.keyId!=_ij){if(a.keyId==_Ny)return;if(u(b)){if(b.action==a.action){if(Date.now()-n>(b.repeat?300:600)||!_Yh(d))b.repeat=(b.repeat||1)+1,l(e[0]);return}if("U"==a.action&&"D"==b.action&&!(1<b.repeat)&&_Yh(d)){v(e[1],
a.keyId)&&v(e[2],a.keyId)?(e[2].value.repeat=(e[2].value.repeat||1)+(e[1].value.repeat||1)+1,l(e[2]),m(e[1]),m(e[0])):(b.action="DU",l(e[0]));return}}}if(d.devId==_ps&&d.type==_Ku&&f)return}c.before(t(a));n=Date.now()}},g=function(a,c){let d=$("devInput sep.edit",c);z(a,d);a=$("devInput > cont",c)[0];450<a.offsetWidth&&$(a).width(a.offsetWidth);250>a.offsetHeight&&$(a).height(a.scrollHeight);d[0].scrollIntoViewIfNeeded()};var _8=function(a,c){return $(`\n <div><l>Group:</l> ${_ow(x,a.params.group,
"group","",!0)} <h h=grp></h></div>\n `)};let x={0:"Default group",1:"Group 1",2:"Group 2",3:"Group 3",4:"Group 4",5:"Group 5",6:"Group 6",7:"Group 7",8:"Group 8",9:"Group 9",10:"Group 10"};var _Er=function(a,c){function d(){$("devInput.edit",c)[0]||($("devInput",c).addClass("edit"),$("devInput sep.edit",c)[0]||$("devInput sep:last-of-type",c).addClass("edit"),$("devInput sep.edit",c)[0].scrollIntoViewIfNeeded(),$(c).attr("dontCloseOnFocusLost",""),_hf._Nf(!0,(b,h)=>{let y;h.in(_7r,_7r|_Go)&&(y=$(":hover").last().closest("devInput.edit inp")[0])?
h!=_7r&&m(y):g(h,c)}),setTimeout(()=>{$(window).captureEvt("mousedown.devInput click.devInput",function(b){b.target.closest("devInput inp")?f():b.target.closest("devInput :-webkit-any(sep, bar)")||(b.target.closest("devInput inpSeq")?g(_mw|("mousedown"==b.type?_Ku:_Go),c):b.target.closest("devInput, devInpMenu")||(f(),b.stopImmediatePropagation()))}).on("blur.devInput",()=>f())}))}function f(){_hf._Nf(!1);$("devInpMenu").triggerEvt("focusLost",!0);$("devInput, devInput .edit",c).removeClass("edit");
$(c).removeAttr("dontCloseOnFocusLost");$(window).off(".devInput").delEvtCapture(".devInput");$("inpSeq",c).triggerEvt("change",!0)}a=a.params;$(c).on("click","devInput inpSeq",function(b){b.target.closest("inp")||d()}).on("mousedown","devInput sep",function(){$(this).addClass("edit").siblings().removeClass("edit")}).on("mousedown","devInput inp",function(b){_Jh(A(this),this,"btrl","tailOnly noTail")}).on("contextmenu","devInput inp",!1).on("mousedown","bar btn[menu]",function(){_Jh(B($(this).attr("menu"),
c),this,"brlt","tailAndShadow noTail")}).on("click","bar btn[pause]",function(){g(_Ny,c)}).on("mousedown","adv",function(b){$("[unused]",b.delegateTarget).slideToggle(200)}).on("DOMInserted",function(){let b=$(".initialMaxDims",this);450<=b.width()&&b.width(b.width());(250<=b.height()||b.height()>$("inpSeq",b).height())&&b.height(b.height());b.removeClass("initialMaxDims")});let e=a.queue||a.group&&"0"!=a.group||a.intoPage||a.keepModKeys?"":"unused";return _Bj`\n <div><devInput style="--placeholder: 'Enter keys and buttons...'">\n <cont class=initialMaxDims><inpSeq name=inputSeq value=[]>\n ${(a.inputSeq||
[]).map(t)}<sep></sep>\n </inpSeq></cont>\n <bar popupCntr><b1><h h=seq></h></b1><b2><btn menu=kybrd>Keyboard</btn><btn menu=mouse>Mouse</btn><btn pause>Pause</btn></b2></bar>\n </devInput></div>\n <div>&nbsp;Times: <input type=number name=times value=${a.times||1} min=1> <h h=tms></h> <adv ${e}>Advanced options</adv></div>\n <div ${e} hr></div>\n <div ${e}><label>${_io("keepModKeys",a.keepModKeys)}Keep modifier keys state</label> <h h=kms></h></div>\n <div ${e}><label>${_io("intoPage",a.intoPage,
"perms=hst")}Send from the inside of webpage</label> <h h=ipg></h></div>\n <!--div ${e}><label>${_io("stopOther",a.stopOther)}Stop other synthetic-input actions</label> <h h=stp></h></div-->\n <div ${e}><l>Postpone actions:</l> ${_ow({"":"All actions",group:"Group only"},a.queue,"queue")} <h h=qeu></h></div>\n <div ${e}><l>Action group:</l> ${_ow(x,a.group,"group")} <h h=grp></h></div>\n `};let A=function(a){a=a.value;let c=k(a.keyId);var d=a.keyId==_sg;d=_Yh(c)?{D:"Press",U:"Release",DU:"Press & Release"}:
{D:d?"Right":"Down",U:d?"Left":"Up"};let f=a.wrtObj?"":"greyedout",e=a.anim||0;return $(`\n <optPane inputDev=${q(c.devId)} ${a.keyId==_ij?"move":""} dataModule value={}>\n <par name=keyId value=${a.keyId} number></par>\n <div act><l>Action:</l> ${_ow(d,a.action,"action")} <!--h h=act></h--></div>\n <div hld><l>Pause:</l> <input type=number name=hold min=0 max=10 step=0.1 value="${a.hold||0}"> secs <h h=hld></h></div>\n <div rep><l>Times:</l> <input type=number name=repeat min=1 max=999 value=${a.repeat||
1}> <h h=rpt></h></div>\n <div pos><l>X:</l> <input type=number name=dX step=5 value=${a.dX||0}>\n Y: <input type=number name=dY step=5 value=${a.dY||0}> <h h=xy></h></div>\n <div pos><l>Relative to:</l> ${_ow({[_W]:"Mouse",[_C]:"Window",[_eo]:"Monitor",[_uo]:"Desktop"},a.wrtObj,"wrtObj","number")} <h h=wrt></h></div>\n <div wrt ${f}><l></l> ${_ow({B:"Left",M:"Center",E:"Right"},a.wrtHorz,"wrtHorz")}\n ${_ow({B:"Top",M:"Middle",E:"Bottom"},a.wrtVert,"wrtVert")} <h h=wrtHV></h></div>\n <div ani><l>Animate:</l> <input type=number name=anim min=0 max=10 step=0.1 value=${e}> secs <h h=ani></h></div>\n <div ani blk ${e?
"":"greyedout"}>&nbsp;<label>${_io("noMovBlk",a.noMovBlk)}Allow physical motion</label> <h h=noBl></h></div>\n <div pse><l>Pause for:</l> <input type=number name=hold min=0 max=999 step=0.1 value=${a.hold||0}> secs</div> \n <div actions> <btn del>Delete element</btn></div>\n </optPane>\n `).change(function(){let b=this.closest("[popupCntr]").popupTriggerElem;b.value=_Uu(this);$(b).triggerEvt("change",!0);l(b)}).on("change","[name=wrtObj]",function(b){$("div[wrt]",b.delegateTarget).attr("greyedout",
this.value==_W?"":null)}).on("change","[name=anim]",function(b){$("div[ani][blk]",b.delegateTarget).attr("greyedout",0<this.value?null:"")}).on("dblclick","[actions] [del]",function(){$(this).triggerEvt("focusLost",!0);let b=this.closest("[popupCntr]").popupTriggerElem,h=b.parentElement;m(b);$(h).triggerEvt("change",!0)})},B=function(a,c){return _Bj($)`<devInpMenu><grp>\n ${C[a].map(d=>"brk"==d?"</grp><grp>":`<item kId=${d.kId}>${d.name||p(d.kId)}</item>`)}\n </grp></devInpMenu>`.on("click","item",
function(){$(this).triggerEvt("focusLost",!0);let d=+$(this).attr("kId");g(d|_Ku,c);_Yh(k(d))&&g(d|_Go,c)})},C={mouse:[{kId:_ij},{kId:_mw},{kId:_7r},{kId:_vt},{kId:_Be},{kId:_ny},{kId:_af},{kId:_sg}],kybrd:[{kId:_Zi},{kId:_cp},{kId:_Up},{kId:_8a},{kId:_5j},{kId:_ru},{kId:_Ie},{kId:_ej},"brk",{kId:_ht},{kId:_Or},{kId:_Xu},{kId:_6j},{kId:_vs},{kId:_Eh},{kId:_4t},{kId:_lk}]}};
